package io.yizoo.system.mapper;

import io.elm.core.Dtor;

import java.util.Map;

public class yizoomanager_sys_trialMapperProvider {
    public static String insertData(Map<String,Object> factor) {
        String sql = Dtor.getSql("insert into yizoomanager.sys_trial(id,phone,org,login_time)" +
                " values(#{id},#{phone},#{org},#{login_time})",factor);
        return sql;
    }

    public static String SelectUserMenuTree(Map<String,Object> factor) {
        String sql = Dtor.getSql("WITH RECURSIVE sys_menu_tree AS (\n" +
                "            SELECT\n" +
                "                 t.*,\n" +
                "                0 AS level,\n" +
                "                CONCAT(LPAD(CAST(t.sort AS CHAR), 3, '0'),'_',CAST(t.id AS CHAR(1000))) AS path\n" +
                "            FROM\n" +
                "                sys_menu t\n" +
                "left join sys_role_rel_menu a on a.menu_id=t.id\n" +
                "left join sys_role_rel_user b on b.role_id=a.role_id\n" +
                "            WHERE\n" +
                "                b.user_id=#{user_id}\n" +
                "\t\t\t\t\t\t\n" +
                "            UNION ALL\n" +
                " \n" +
                "            SELECT\n" +
                "                c. *,\n" +
                "                ct.level + 1 AS level,\n" +
                "                CONCAT(ct.path, '_',LPAD(CAST(c.sort AS CHAR), 3, '0'),'_',c.id) AS path\n" +
                "            FROM\n" +
                "                sys_menu c\n" +
                "            INNER JOIN\n" +
                "                sys_menu_tree ct ON c.id = ct.pid\n" +
                "\n" +
                "        )\n" +
                "        SELECT\n" +
                "             distinct id,pid,name,icon,navigateurl,sort,target\n" +
                "        FROM\n" +
                "            sys_menu_tree\n" +
                "        ORDER BY\n" +
                "            path\n" +
                "\t\t\t\t\t\t",factor);
        return sql;
    }
}
